package com.cn.api.controller;

import com.cn.api.error.ExceptionExpand;
import com.cn.api.resource.BaseResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Api(tags = { "有关于session操作" })
@Controller
@RequestMapping("/session")
public class ATest {

	@ResponseBody
	@RequestMapping(value = "addSession", method = RequestMethod.POST)
	@ApiOperation(value = "添加session", httpMethod = "POST", response = BaseResultVo.class, notes = "添加session")
	public String addUser(HttpServletRequest request) throws ExceptionExpand {
		HttpSession session = request.getSession();
		session.setAttribute("userid", "2222");
		return "";
	}

	@ResponseBody
	@RequestMapping(value = "getSession", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	@ApiOperation(value = "获取session", httpMethod = "POST", notes = "获取session")
	public String login(HttpServletRequest request) {
		HttpSession session = request.getSession();
		Object userid = session.getAttribute("userid");
		return "";
	}

}
